 @extends('master')

@section('title')
Scool|Event
@endsection

@section('content')

 <!-- right-top -->
    <div class="right-info" id="scrol3">
      <div class="right-info-wrapper" id="right-info-wrapper">
        <div class="height_16"></div>
        <!-- height_16 -->

        <div class="height_22"></div>
        <!-- height_22 -->
        <div class="table-list-info" id="zohoid-info">
          <div class="panel panel-default">
            <div class="panel-heading"> 修改 event</div>
            <!-- panel-heading -->
            <div class="panel-body panel-body-pad">
              <form id='from'>
              <input type="hidden" id="activityTmpId" value="<?php echo $data->id;?>" />
              <input type="hidden" name="cover_path" id="cover_path" value="" />
                <div class="form-group">
                  <label for="name_en" class="snow">Title</label>
                  <input type="text" class="form-control form-control-inline" id="title" name="title" placeholder="标题" value="<?php echo $data->title;?>" />
             </div>
              <div class="form-group">
                  <label for="name_cn" class="snow">Cover</label><br />
                  {{--<input type="text" class="form-control form-control-inline" id="cover_path" name="cover_path" placeholder="图片">--}}
                  <img id="cover_path_src" src="<?php echo $data->cover_path_src;?>" width="100" />
                  <input id="input-4" name="pics[]" type="file" multiple class="file-loading">
             </div>
                <div class="form-group">
                  <label for="country_en" class="snow">Description</label><br />
                  <textarea rows="10" cols="80" id="description" name="description"><?php echo $data->description;?></textarea>
                </div>
                 <div class="form-group">
                  <label for="country_cn" class="snow">Start time</label>
                 <input type="text" class="form-control form-control-inline" id="create_time" name="create_time" placeholder="开始时间" readonly="true" value="<?php echo $data->create_time;?>" />
                </div>
                 <div class="form-group">
                  <label for="location" class="label-margin">End time</label>
                 <input type="text" class="form-control form-control-inline" id="end_time" name="end_time" placeholder="结束时间" readonly="true" value="<?php echo $data->end_time;?>" />
                </div>
                 <div class="form-group">
                  <label for="address" class="label-margin">Address:</label>
                 <input type="text" class="form-control form-control-inline" id="address" name="address" placeholder="详细地址" value="<?php echo $data->address;?>" />
                </div>
                <div class="form-group">
                  <label for="country_cn" class="snow">Public</label>
                 <select class="form-control form-control-inline" name="is_public" id="is_public">
                 <option value="1">公开活动</option>
                 </select>
                </div>
                <div class="form-group">
                  <label for="country_cn" class="snow">Free</label>
                 <select class="form-control form-control-inline" name="is_free" id="is_free" onchange="changeTicket();">
                 <option value="0">收费</option>
                 </select>
                </div>
                <div class="form-group" id="ticket" <?php if($data->is_free):?>style="display: none;"<?php endif;?>>
                <div style="float: left;width:20%;">
                    早鸟会员价<input type="text" class="form-control form-control-inline" id="ticket_eb_title" name="ticket_eb[name]" placeholder="标题" value="<?php if(isset($data->ticket['ticket_eb']->name)){echo $data->ticket['ticket_eb']->name;}?>"><br />
                     Ticket currency<select class="form-control form-control-inline" id="ticket_eb_currency" name="ticket_eb[currency]">
                     <option value="USD" <?php if(isset($data->ticket['ticket_eb']->currency) && ('USD' == $data->ticket['ticket_eb']->currency)):?>selected="selected"<?php endif;?>>USD</option>
                     <option value="GBP" <?php if(isset($data->ticket['ticket_eb']->currency) && ('GBP' == $data->ticket['ticket_eb']->currency)):?>selected="selected"<?php endif;?>>GBP</option>
                     <option value="CNY" <?php if(isset($data->ticket['ticket_eb']->currency) && ('CNY' == $data->ticket['ticket_eb']->currency)):?>selected="selected"<?php endif;?>>CNY</option>
                     </select><br />
                     Ticket price<input type="text" class="form-control form-control-inline" id="ticket_eb_price" name="ticket_eb[price]" placeholder="价格" value="<?php if(isset($data->ticket['ticket_eb']->price)){echo $data->ticket['ticket_eb']->price;}?>" /><br />
                     Ticket count<input type="text" class="form-control form-control-inline" id="ticket_eb_count" name="ticket_eb[count]" placeholder="数量" value="<?php if(isset($data->ticket['ticket_eb']->count)){echo $data->ticket['ticket_eb']->count;}?>" /><br />
                     早鸟截止时间<input type="text" class="form-control form-control-inline" id="early_bird_deadline" name="ticket_eb[early_bird_deadline]" placeholder="截止时间" readonly="true" value="<?php if(isset($data->ticket['ticket_eb']->early_bird_deadline)){echo $data->ticket['ticket_eb']->early_bird_deadline;}?>">
                </div>
                <div style="float: left;width:20%;margin-left: 10px;">
                    早鸟非会员价<input type="text" class="form-control form-control-inline" id="ticket_eb_f_title" name="ticket_eb_f[name]" placeholder="标题" value="<?php if(isset($data->ticket['ticket_eb_f']->name)){echo $data->ticket['ticket_eb_f']->name;}?>" /><br />
                     Ticket currency<select class="form-control form-control-inline" id="ticket_eb_f_currency" name="ticket_eb_f[currency]">
                     <option value="USD" <?php if(isset($data->ticket['ticket_eb_f']->currency) && ('USD' == $data->ticket['ticket_eb_f']->currency)):?>selected="selected"<?php endif;?>>USD</option>
                     <option value="GBP" <?php if(isset($data->ticket['ticket_eb_f']->currency) && ('GBP' == $data->ticket['ticket_eb_f']->currency)):?>selected="selected"<?php endif;?>>GBP</option>
                     <option value="CNY" <?php if(isset($data->ticket['ticket_eb_f']->currency) && ('CNY' == $data->ticket['ticket_eb_f']->currency)):?>selected="selected"<?php endif;?>>CNY</option>
                     </select><br />
                     Ticket price<input type="text" class="form-control form-control-inline" id="ticket_eb_f_price" name="ticket_eb_f[price]" placeholder="价格" value="<?php if(isset($data->ticket['ticket_eb_f']->price)){echo $data->ticket['ticket_eb_f']->price;}?>" /><br />
                     Ticket count<input type="text" class="form-control form-control-inline" id="ticket_eb_f_count" name="ticket_eb_f[count]" placeholder="数量" value="<?php if(isset($data->ticket['ticket_eb_f']->count)){echo $data->ticket['ticket_eb_f']->count;}?>" />
                </div>
                <div style="float: left;width:20%;margin-left: 10px;">
                 会员价<input type="text" class="form-control form-control-inline" id="ticket_mb_title" name="ticket_mb[name]" placeholder="标题" value="<?php if(isset($data->ticket['ticket_mb']->name)){echo $data->ticket['ticket_mb']->name;}?>" /><br />
                 Ticket currency<select class="form-control form-control-inline" id="ticket_mb_currency" name="ticket_mb[currency]">
                 <option value="USD" <?php if(isset($data->ticket['ticket_mb']->currency) && ('USD' == $data->ticket['ticket_mb']->currency)):?>selected="selected"<?php endif;?>>USD</option>
                 <option value="GBP" <?php if(isset($data->ticket['ticket_mb']->currency) && ('GBP' == $data->ticket['ticket_mb']->currency)):?>selected="selected"<?php endif;?>>GBP</option>
                 <option value="CNY" <?php if(isset($data->ticket['ticket_mb']->currency) && ('CNY' == $data->ticket['ticket_mb']->currency)):?>selected="selected"<?php endif;?>>CNY</option>
                 </select><br />
                 Ticket price<input type="text" class="form-control form-control-inline" id="ticket_mb_price" name="ticket_mb[price]" placeholder="价格" value="<?php if(isset($data->ticket['ticket_mb']->price)){echo $data->ticket['ticket_mb']->price;}?>" /><br />
                 Ticket count<input type="text" class="form-control form-control-inline" id="ticket_mb_count" name="ticket_mb[count]" placeholder="数量" value="<?php if(isset($data->ticket['ticket_mb']->count)){echo $data->ticket['ticket_mb']->count;}?>" />
                </div>
                <div style="float: left;width:20%;margin-left: 10px;">
                 非会员价<input type="text" class="form-control form-control-inline" id="ticket_mb_f_title" name="ticket_mb_f[name]" placeholder="标题" value="<?php if(isset($data->ticket['ticket_mb_f']->name)){echo $data->ticket['ticket_mb_f']->name;}?>" /><br />
                 Ticket currency<select class="form-control form-control-inline" id="ticket_mb_f_currency" name="ticket_mb_f[currency]">
                 <option value="USD" <?php if(isset($data->ticket['ticket_mb_f']->currency) && ('USD' == $data->ticket['ticket_mb_f']->currency)):?>selected="selected"<?php endif;?>>USD</option>
                 <option value="GBP" <?php if(isset($data->ticket['ticket_mb_f']->currency) && ('GBP' == $data->ticket['ticket_mb_f']->currency)):?>selected="selected"<?php endif;?>>GBP</option>
                 <option value="CNY" <?php if(isset($data->ticket['ticket_mb_f']->currency) && ('CNY' == $data->ticket['ticket_mb_f']->currency)):?>selected="selected"<?php endif;?>>CNY</option>
                 </select><br />
                 Ticket price<input type="text" class="form-control form-control-inline" id="ticket_mb_f_price" name="ticket_mb_f[price]" placeholder="价格" value="<?php if(isset($data->ticket['ticket_mb_f']->price)){echo $data->ticket['ticket_mb_f']->price;}?>" /><br />
                 Ticket count<input type="text" class="form-control form-control-inline" id="ticket_mb_f_count" name="ticket_mb_f[count]" placeholder="数量" value="<?php if(isset($data->ticket['ticket_mb_f']->count)){echo $data->ticket['ticket_mb_f']->count;}?>" />
                </div>

                </div>
              </form>
            </div>
            <!-- panel-body -->
            <ul class="list-group">
              <li class="list-group-item" id="adminButton">
              <?php if($data->isAdmin):?>
              <button type="submit" class="btn btn-default btn-pad" id="adminSubmit"> 确认发布 </button>
              <button type="submit" class="btn btn-default btn-pad" id="adminReturn"> 退回 </button>
              <?php else:?>
                <button type="submit" class="btn btn-default btn-pad" id="submit"> OK </button>
              <?php endif;?>
              </li>
            </ul>
          </div>
          <!-- panel -->
        </div>
        <!-- table-list-info -->

      </div>
      <!-- right-info-wrapper -->
    </div>
    <!-- right-info -->


    @endsection

@section('js')
<script type="text/javascript"  src="/js/event/updatetmp.js"></script>
<script>
    $('#create_time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii:ss'
    });
    $('#end_time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii:ss'
    });
    $('#early_bird_deadline').datetimepicker({
        format: 'yyyy-mm-dd hh:ii'
    });
    $(document).on('ready', function() {
        $("#input-4").fileinput({
        uploadUrl:'/event/uploadfile',   //上传地址
        allowedFileExtensions: ['jpg', 'png', 'gif', 'jpeg'],   //接收的文件后缀
        showUpload: false,  //是否显示上传按钮
        maxFileCount:1,     //最多上传图片数量
        showCaption: false
        });
    });
    $("#input-4").on("fileuploaded", function(event, data, previewId, index) {
        if(1 == data.response.status){
            $('#cover_path').val(data.response.msg);
//            alert(data.response.msg);
        }
    });
    function changeTicket()
    {
        if(0 == $("#is_free").val()){
            $("#ticket").show();
        }else{
            $("#ticket").hide();
        }
    }
    $('#adminReturn').click(function(){
        layer.open({
            type: 1,
            skin: 'layui-layer-rim', //加上边框
            area: ['620px', '320px'], //宽高
            title: '填写退回信息',
            shadeClose: true, //开启遮罩关闭
            content:
            "<div class='tag_update_form'>"+
            "<div class='form-group'>"+
            "<textarea rows='5' cols='30' id='return_reason' name='return_reason' style='margin: 30px 0px 0px 30px;'></textarea>"+
            "</div>"+
            " <button type='submit' class='btn btn-default btn-pad' id='returnSubmit' onclick='returnSubmit();'> OK </button>"+
            "</div>"
        });
    });
    function returnSubmit()
    {
        var returnReason = $('#return_reason').val();
        var activityTmpId = $('#activityTmpId').val();
        $.post("/event/return",
        	{ returnReason:returnReason, id:activityTmpId },
                function(result){
                if(result.status == true){

                    $.successAlert(result.msg);

                    setTimeout(function (){window.location.href='/event/tmp'}, 3000)
                }else{
                    $.errorAlert(result.msg);

                    btn.button('reset')

                    return false;
                }
        	},"json");
    }

</script>
@endsection